bitwise even or odd

131

bitwise even or odd -

// C# program to check for even or odd
// using Bitwise AND operator
using System;
 
class GFG
{
     
    // Returns true if n is even, else odd
    static bool isEven(int n)
    {
        // n&1 is 1, then odd, else even
        return ((n & 1) != 1);
    }
         
    // Driver code
    public static void Main()
    {
        int n = 101;
        Console.Write(isEven(n) == true ? "Even" : "Odd");
    }
}
 
// This code is contributed by AnkitRai01

Comments

Submit
0 Comments